package com.sim.contact.tool.contacts;

import android.provider.ContactsContract;

public class Address {
    private String poBox;
     private String street;
     private String city;
     private String region;
     private String postalCode;
     private String country;
     private int type;
     private String asString = "";
     
     public int getType() {
         return type;
     }
     public void setType(int type) {
         this.type = type;
     }
     public String getPoBox() {
         return poBox;
     }
     public void setPoBox(String poBox) {
         this.poBox = poBox;
     }
     public String getStreet() {
         return street;
     }
     public void setStreet(String street) {
         this.street = street;
     }
     public String getCity() {
         return city;
     }
     public void setCity(String city) {
         this.city = city;
     }
     public String getRegion() {
         return region;
     }
     public void setRegion(String state) {
         this.region = state;
     }
     public String getPostalCode() {
         return postalCode;
     }
     public void setPostalCode(String postalCode) {
         this.postalCode = postalCode;
     }
     public String getCountry() {
         return country;
     }
     public void setCountry(String country) {
         this.country = country;
     }
     public String toString() {
         if (this.asString.length() > 0) {
             return(this.asString);
         } else {
             String addr = getTypeName()+":";
             if (this.getPoBox() != null) {
                 addr = addr + this.getPoBox() + "n";
             }
             if (this.getStreet() != null) {
                 addr = addr + this.getStreet() + "n";
             }
             if (this.getCity() != null) {
                 addr = addr + this.getCity() + ", ";
             }
             if (this.getRegion() != null) {
                 addr = addr + this.getRegion() + " ";
             }
             if (this.getPostalCode() != null) {
                 addr = addr + this.getPostalCode() + " ";
             }
             if (this.getCountry() != null) {
                 addr = addr + this.getCountry();
             }
             return(addr);
         }
     }
     
     public Address(String asString, int type) {
         this.asString = asString;
         this.type = type;
     }
     
     public Address(String poBox, String street, String city, String region, 
             String postal, String country, int type) {
         this.setPoBox(poBox);
          this.setStreet(street);
         this.setCity(city);
         this.setRegion(region);
         this.setPostalCode(postal);
         this.setCountry(country);
         this.setType(type);
     }
     
     private String getTypeName(){
      	String name="";
      	switch (type) {
  		case ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME:
  			name = "住宅";
  			break;
  		case ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK:
  			name = "工作";
  			break;
  		default:
  			name = "其他";
  			break;
  		}
      	
      	return name;
      }
}